package com.hongyu.manager.media.manager.model.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class Page {
    /**
     * 当前页
     */
    private Long pageNum;
    /**
     * 每页条数
     */
    private Integer pageSize;

    /**
     * 总条数
     */
    private Integer totalSize;
    /**
     * 总页数
     */
    private Integer totalPage;
    /**
     * 类型
     */
    @JsonIgnore
    private Integer type;
    /**
     * 中间位置
     */
    @JsonIgnore
    private Integer middle;

    public Page(Long pageNum, Integer pageSize, Integer totalSize) {
        this.pageNum = pageNum;
        this.totalSize = totalSize;
        this.pageSize = pageSize;
        this.totalPage = getTotalPage(pageSize, totalSize);
    }

    private Integer getTotalPage(Integer pageSize, Integer totalSize) {
        Integer totalPage = totalSize / pageSize;
        if (totalSize % pageSize != 0){
            totalPage++;
        }
        return totalPage;
    }

    public Long getPageNum() {
        return pageNum;
    }

    public void setPageNum(Long pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(Integer totalSize) {
        this.totalSize = totalSize;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
        this.middle = type / 2;
    }

    public Integer getMiddle() {
        return middle;
    }
}

